{include file="index/head" /}
<div class="box auto">
  <form method="post" action="" class="sycmsform">
    <div class="box-head"> 生成列表 </div>
    <div class="form">
      <ul>
         <li>
          <label>生成电脑端或移动端：</label>
          <div class="item">
            <div class="select"><i class="icon-caret-down"></i>
              <input type="hidden" name="htmlpath" value="0" class="inputval" />
              <input type="text" readonly="readonly" class="input"  placeholder="请选择生成电脑端或移动端"/>
              <dl class="select-value syui-anim syui-anim-up">
                <dd data="0" class=selected>电脑端</dd>
                <dd data="1">移动端</dd>
              </dl>
            </div>          
          </div>
        </li>
        <li>
          <label>请选择栏目：</label>
          <div class="item">
            <div class="select"><i class="icon-caret-down"></i>
              <input type="hidden" name="nid" value="0" class="inputval" />
              <input type="text" readonly="readonly" class="input"  placeholder="请选择栏目"/>
              <dl class="select-value syui-anim syui-anim-up">
                <dd data="0">生成所有分类</dd>
                {volist name="list" id="vo"}
                <dd data="{$vo.id}" onclick="getcate({$vo.id})">{$vo.title}({$vo.count})</dd>
                {/volist}
              </dl>
            </div> 
            <span class="tips">不选择默认生成所有分类</span>           
          </div>
        </li>
				<li>
				  <label>请选分类：</label>
				  <div class="item">
				    <div class="select"><i class="icon-caret-down"></i>
				      <input type="hidden" name="cid" value="0" class="inputval" />
				      <input type="text" id="cidtitle" readonly="readonly" class="input"  placeholder="请选分类"/>
				      <dl class="select-value syui-anim syui-anim-up" id="cate">
				        <dd data="0">生成所有分类</dd>				        
				      </dl>
				    </div> 
				    <span class="tips">不选择默认生成所有分类</span>           
				  </div>
				</li>
        <li>
          <label>&nbsp;</label>
          <div class="item">
            <button type="button" onclick="createHtml()" class="button"><i class="icon-check"></i>点击生分类页</button>
          </div>
        </li>
      </ul>
    </div>
  </form>
</div>

<script>
function createHtml(){
	var nid = $("input[name=nid]").val();
	var cid = $("input[name=cid]").val();	
	var htmlpath = $("input[name=htmlpath]").val();	
	layer.open({
		type:2,
		title:'开始分类页',
		area: ['650px', '400px'],
		content:'{:url("Chtml/doCate")}?process_nid='+nid+'&htmlpath='+htmlpath+'&process_cid='+cid
	})
}

function getcate(nid){
	$("#cate").html('');	
	$("input[name=cid]").val("");
	$("#cidtitle").val("");
	layer.load();
	$.post("{:url('Chtml/getcate')}",{nid:nid},function(res){
		 layer.closeAll();
		 var data = res.data;		 
		 var html = '';
		 for(var i = 0; i < data.length; i++){
			 html+='<dd data='+data[i].id+'><b>'+data[i].title+'</b></dd>';
			 for(var b = 0; b < data[i].son.length; b++){   
			   html+='<dd data='+data[i].son[b].id+'>'+data[i].son[b].title+'</dd>';
			 }	
		 }
		 $("#cate").html(html);
	},'json')
}
</script>
